#include "ParticleSystem.h"
#include "iRenderer.h"
#include <list>
#include <cmath>

using namespace neiderra::rendering;

Particle::Particle()
{
}

Particle::~Particle()
{
}

PolyParticle::PolyParticle() : Particle() {
	texture = 0;
}

PolyParticle::~PolyParticle()
{
}

int ParticleSystem::remove(Particle* p)
{
	_particles.remove(p);
	return 1;
}

int ParticleSystem::update(double deltaT)
{
	Particles::iterator i = _particles.begin();

	for(;i!=_particles.end();i++)
	{
		Particle* p = *i;
		p->update(deltaT);
	}
	return 1;
}

void ParticleSystem::render(iRenderer* r)
{
	r->render(this);
}

Particle* ParticleSystem::add()
{
	Particle* p = new Particle();
	p->lifetime = _time;
	_particles.push_back(p);
	return p;
}

PolyParticleSystem::PolyParticleSystem()
{
}

PolyParticleSystem::~PolyParticleSystem()
{
}

Particle* PolyParticleSystem::add()
{
	PolyParticle* pp = new PolyParticle();
	(*pp).lifetime = getMaxLifetime();
	_particles.push_back(pp);
	return pp;
}

void PolyParticleSystem::render(iRenderer* r)
{
	r->render(this);
}

void PolyParticleSystem::initParticles()
{
}

int PolyParticleSystem::update(double deltaT)
{
	return 0;
}
